/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Log4jLoaderDialog.java
 *
 * Created on 7 May, 2010, 1:10:26 PM
 */

package com.gs.logviewer.mockup;

import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.JTextField;

/**
 *
 * @author sabuj.das
 */
public class Log4jLoaderDialog extends javax.swing.JDialog {

    /** Creates new form Log4jLoaderDialog */
    public Log4jLoaderDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
		populateLoggerConfiguration();
    }

	public void populateLoggerConfiguration(){
		for(int i=0; i<10; i+=4){
			java.awt.GridBagConstraints gridBagConstraints;
			JLabel appenderLabel = new JLabel();
			appenderLabel.setText("Appender: ");
			appenderLabel.setName("appenderLabel"); // NOI18N
			gridBagConstraints = new java.awt.GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = i+0;
			gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
			configurationPanel.add(appenderLabel, gridBagConstraints);

			JLabel appenderNameLabel = new JLabel();
			appenderNameLabel.setForeground(new java.awt.Color(0, 51, 204));
			appenderNameLabel.setText("APPENDER");
			appenderNameLabel.setName("appenderNameLabel"); // NOI18N
			gridBagConstraints = new java.awt.GridBagConstraints();
			gridBagConstraints.gridx = 1;
			gridBagConstraints.gridy = i+0;
			gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
			gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
			configurationPanel.add(appenderNameLabel, gridBagConstraints);

			JLabel filePathLabel = new JLabel();
			filePathLabel.setText("Full file path: ");
			filePathLabel.setName("filePathLabel"); // NOI18N
			gridBagConstraints = new java.awt.GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = i+1;
			gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
			configurationPanel.add(filePathLabel, gridBagConstraints);

			JTextField logFileNameTextField = new JTextField();
			logFileNameTextField.setEditable(false);
			logFileNameTextField.setForeground(new java.awt.Color(0, 0, 204));
			logFileNameTextField.setName("logFileNameTextField"); // NOI18N
			gridBagConstraints = new java.awt.GridBagConstraints();
			gridBagConstraints.gridx = 1;
			gridBagConstraints.gridy = i+1;
			gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
			gridBagConstraints.weightx = 1.0;
			gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
			configurationPanel.add(logFileNameTextField, gridBagConstraints);

			JButton browseFileButton = new JButton();
			browseFileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/folder_open.png"))); // NOI18N
			browseFileButton.setToolTipText("Browse");
			browseFileButton.setName("browseFileButton"); // NOI18N
			gridBagConstraints = new java.awt.GridBagConstraints();
			gridBagConstraints.gridx = 2;
			gridBagConstraints.gridy = i+1;
			gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
			configurationPanel.add(browseFileButton, gridBagConstraints);

			JLabel patternLabel = new JLabel();
			patternLabel.setText("Conversion Pattern:");
			patternLabel.setName("patternLabel"); // NOI18N
			gridBagConstraints = new java.awt.GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = i+2;
			gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
			configurationPanel.add(patternLabel, gridBagConstraints);

			JTextField patternTextField = new JTextField();
			patternTextField.setEditable(false);
			patternTextField.setForeground(new java.awt.Color(0, 0, 204));
			patternTextField.setName("patternTextField"); // NOI18N
			gridBagConstraints = new java.awt.GridBagConstraints();
			gridBagConstraints.gridx = 1;
			gridBagConstraints.gridy = i+2;
			gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
			gridBagConstraints.weightx = 1.0;
			gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
			configurationPanel.add(patternTextField, gridBagConstraints);

			JSeparator confSeparator = new JSeparator();
			confSeparator.setName("confSeparator"); // NOI18N
			gridBagConstraints = new java.awt.GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = i+3;
			gridBagConstraints.gridwidth = 3;
			gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
			gridBagConstraints.weightx = 1.0;
			gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
			configurationPanel.add(confSeparator, gridBagConstraints);

		}
		configurationPanel.repaint();
		configurationPanel.updateUI();
        configurationScrollPane.setViewportView(configurationPanel);
		log4gViewerPanel.updateUI();
	}

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        filenameTextField = new javax.swing.JTextField();
        browseButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        log4gViewerPanel = new javax.swing.JPanel();
        configurationScrollPane = new javax.swing.JScrollPane();
        configurationPanel = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new java.awt.GridBagLayout());

        jLabel1.setText("File Name  ");
        jLabel1.setName("jLabel1"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(jLabel1, gridBagConstraints);

        filenameTextField.setName("filenameTextField"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(filenameTextField, gridBagConstraints);

        browseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/folder_open_file.png"))); // NOI18N
        browseButton.setText("Browse");
        browseButton.setName("browseButton"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(browseButton, gridBagConstraints);

        jSeparator1.setName("jSeparator1"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(jSeparator1, gridBagConstraints);

        log4gViewerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, " Log4j Configuration : ", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(0, 51, 255))); // NOI18N
        log4gViewerPanel.setName("log4gViewerPanel"); // NOI18N
        log4gViewerPanel.setLayout(new java.awt.BorderLayout());

        configurationScrollPane.setName("configurationScrollPane"); // NOI18N

        configurationPanel.setBackground(new java.awt.Color(255, 255, 255));
        configurationPanel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 255), 1, true));
        configurationPanel.setName("configurationPanel"); // NOI18N
        configurationPanel.setLayout(new java.awt.GridBagLayout());
        configurationScrollPane.setViewportView(configurationPanel);

        log4gViewerPanel.add(configurationScrollPane, java.awt.BorderLayout.PAGE_START);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(log4gViewerPanel, gridBagConstraints);

        jButton1.setText("jButton1");
        jButton1.setName("jButton1"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(jButton1, gridBagConstraints);

        jButton2.setText("jButton2");
        jButton2.setName("jButton2"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(jButton2, gridBagConstraints);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Log4jLoaderDialog dialog = new Log4jLoaderDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton browseButton;
    private javax.swing.JPanel configurationPanel;
    private javax.swing.JScrollPane configurationScrollPane;
    private javax.swing.JTextField filenameTextField;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JPanel log4gViewerPanel;
    // End of variables declaration//GEN-END:variables

}
